package com.syys.privacy.controller;


import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.syys.common.annotation.Log;
import com.syys.common.enums.BusinessType;
import com.syys.privacy.domain.QaPersonalInfoMinor;
import com.syys.privacy.service.IQaPersonalInfoMinorService;
import com.syys.common.core.controller.BaseController;
import com.syys.common.core.domain.AjaxResult;
import com.syys.common.utils.poi.ExcelUtil;
import com.syys.common.core.page.TableDataInfo;

/**
 * 个人信息的委托处理、共享、转让和公开披露Controller
 *
 * @author ys
 * @date 2021-07-26
 */
@Controller
@RequestMapping("/privacy/minor")
public class QaPersonalInfoMinorController extends BaseController {
    private String prefix = "privacy/minor";

    @Autowired
    private IQaPersonalInfoMinorService qaPersonalInfoMinorService;

    @GetMapping()
    public String privacy() {
        return prefix + "/privacy";
    }

    /**
     * 查询个人信息的委托处理、共享、转让和公开披露列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(QaPersonalInfoMinor qaPersonalInfoMinor) {
        startPage();
        List<QaPersonalInfoMinor> list = qaPersonalInfoMinorService.selectQaPersonalInfoMinorList(qaPersonalInfoMinor);
        return getDataTable(list);
    }

    /**
     * 导出个人信息的委托处理、共享、转让和公开披露列表
     */
    @Log(title = "个人信息的委托处理、共享、转让和公开披露", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(QaPersonalInfoMinor qaPersonalInfoMinor) {
        List<QaPersonalInfoMinor> list = qaPersonalInfoMinorService.selectQaPersonalInfoMinorList(qaPersonalInfoMinor);
        ExcelUtil<QaPersonalInfoMinor> util = new ExcelUtil<QaPersonalInfoMinor>(QaPersonalInfoMinor.class);
        return util.exportExcel(list, "个人信息的委托处理、共享、转让和公开披露数据");
    }

    /**
     * 新增个人信息的委托处理、共享、转让和公开披露
     */
    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }

    /**
     * 新增保存个人信息的委托处理、共享、转让和公开披露
     */
    @Log(title = "个人信息的委托处理、共享、转让和公开披露", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(QaPersonalInfoMinor qaPersonalInfoMinor) {
        return AjaxResult.success(qaPersonalInfoMinorService.insertQaPersonalInfoMinor(qaPersonalInfoMinor));
    }

    /**
     * 修改个人信息的委托处理、共享、转让和公开披露
     */
    @GetMapping("/edit/{minorId}")
    public String edit(@PathVariable("minorId") Long minorId, ModelMap mmap) {
        QaPersonalInfoMinor qaPersonalInfoMinor = qaPersonalInfoMinorService.selectQaPersonalInfoMinorById(minorId);
        mmap.put("qaPersonalInfoMinor", qaPersonalInfoMinor);
        return prefix + "/edit";
    }

    /**
     * 修改保存个人信息的委托处理、共享、转让和公开披露
     */
    @Log(title = "个人信息的委托处理、共享、转让和公开披露", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(QaPersonalInfoMinor qaPersonalInfoMinor) {
        return toAjax(qaPersonalInfoMinorService.updateQaPersonalInfoMinor(qaPersonalInfoMinor));
    }

    /**
     * 删除个人信息的委托处理、共享、转让和公开披露
     */
    @Log(title = "个人信息的委托处理、共享、转让和公开披露", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(qaPersonalInfoMinorService.deleteQaPersonalInfoMinorByIds(ids));
    }
}